package com.webratio.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class PrintArrayTagHandler extends TagSupport
{
	private static final long serialVersionUID = -4333575109271419036L;
	
	private String[] var;
	
	@Override
	public int doStartTag() throws JspException
	{
		try
		{
			if(var != null)
			{
				//Get the writer object for output.
				JspWriter out = pageContext.getOut();
				
				out.println("<ul>");
				for(int i=0; i<var.length; i++)
				{
					out.println("<li>" + var[i] + "</li>");
				}
				out.println("</ul>");
			}
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		return SKIP_BODY;
	}
	
	public String[] getVar()
	{
		return var;
	}
	
	public void setVar(String[] var)
	{
		this.var = var;
	}
}